using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.ContactsDomain;
using ShivamEMR.Model.DataInterfaces.ContactsDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.Contacts.Models;

namespace ShivamEMR.Web.Areas.Contacts.Controllers
{   
    public class ContactPictureController : Controller
    {
		private readonly IContactPictureRepository contactpictureRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public ContactPictureController()
        {
            contactpictureRepository = Registry.RepositoryFactory.GetContactPictureRepository();
        }

        public ContactPictureController(IContactPictureRepository contactpictureRepository)
        {
			this.contactpictureRepository = contactpictureRepository;
        }

        //
        // GET: /ContactPicture/

        public ViewResult Index()
        {
            return View(contactpictureRepository.All);
        }

        //
        // GET: /ContactPicture/Details/5

        public ViewResult Details(System.Guid id)
        {
            return View(contactpictureRepository.Find(id));
        }

        //
        // GET: /ContactPicture/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /ContactPicture/Create

        [HttpPost]
        public ActionResult Create(ContactPicture contactpicture)
        {
            if (ModelState.IsValid) {
                contactpictureRepository.InsertOrUpdate(contactpicture);
                contactpictureRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /ContactPicture/Edit/5
 
        public ActionResult Edit(System.Guid id)
        {
             return View(contactpictureRepository.Find(id));
        }

        //
        // POST: /ContactPicture/Edit/5

        [HttpPost]
        public ActionResult Edit(ContactPicture contactpicture)
        {
            if (ModelState.IsValid) {
                contactpictureRepository.InsertOrUpdate(contactpicture);
                contactpictureRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /ContactPicture/Delete/5
 
        public ActionResult Delete(System.Guid id)
        {
            return View(contactpictureRepository.Find(id));
        }

        //
        // POST: /ContactPicture/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(System.Guid id)
        {
            var cp = contactpictureRepository.Find(id);
            contactpictureRepository.Delete(cp);
            contactpictureRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

